package com.yanqu.road.server.cmd.monopolymarket.resgrab;

import com.yanqu.road.pb.monopolymarket.MonopolyMarketProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.monopolymarket.MonopolyMarketResGrabMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;

/**
 * @Description
 * @Author cwq
 * @Data 2021/8/12 17:08
 */
@Cmd(code = Protocol.C_CROSS_MONOPOLY_MARKET_RES_GRAB_ENTER, desc = "进入资源争夺战 大厅")
public class CrossMonopolyMarketResGrabEnterCmd extends CrossCommand {

    private long userId;
    private List<MonopolyMarketProto.MonopolyMarketResGrabEnterParamEntity> pageList;
    private int type;
    private boolean isGetNotice;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        MonopolyMarketProto.MonopolyMarketEnterResGrabReqMsg req = MonopolyMarketProto.MonopolyMarketEnterResGrabReqMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        pageList = req.getPageParamList();
        type = req.getType();
        isGetNotice = req.getIsGetNotice();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        MessageHelper.sendPacket(serverId, userId , YanQuMessageUtils.buildMessage(ClientProtocol.U_MONOPOLY_MARKET_RES_GRAB_ENTER, MonopolyMarketResGrabMgr.enterResGrab(type, pageList, serverId,isGetNotice)));
    }

    @Override
    public void sendData() {

    }
}
